home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / dtr.arc / dtr.c next >
C/C++ Source or Header  |  1987-01-18  |  3KB  |  100 lines

  1. /*
  2.    DTR control program. Called from Shell or Desktop. Rename to DTR.PRG
  3.        if placed in AUTO folder.
  4.    Call:
  5.        DTR {"on"|"off"}
  6.    Assumes "off" if no argument.
  7.  
  8. Written by Bruce D. Nelson 1/18/87 Megamax C.
  9. */
  10.  
  11. #include <osbind.h>
  12. #include <string.h>
  13.  
  14. extern giaccess();
  15. extern rdbt();
  16. extern dtron();
  17. extern dtroff();
  18. extern setbt();
  19. extern clrbt();
  20.  
  21.  
  22. asm{
  23.  
  24. giaccess:
  25.     move.w    SR,-(A7)    /* save status */
  26.     ori.w    #0x700,SR    /* IPL 7, disable ints */
  27.     movem.l D1-D2/A0,-(A7)    /* Save regs */
  28.     lea    0xFFFF8800,A0    /* Adr of Sound Chip */
  29.     move.b    D1,D2        /* Get reg # */
  30.     and.b    #15,D1        /* reg 0-15 */
  31.     move.b    D1,(A0)        /* select reg */
  32.     asl.b    #1,D2        /* test read/write bit */
  33.     bcc    rdbt(PC)    /* go read */
  34.     move.b    D0,2(A0)    /* write data to sound chip register */
  35. rdbt:    moveq   #0,D0
  36.     move.b    (A0),D0        /* read byte from sound chip register */
  37.     movem.l (A7)+,D1-D2/A0  /* restore registers */
  38.     move.w    (A7)+,SR    /* restore status */
  39.     rts
  40.  
  41. dtroff:
  42.     moveq    #16,D2        /* set dtr bit */
  43.     bra    setbt(PC)    /* go set bit */
  44.  
  45. dtron:
  46.     moveq     #-17,D2        /* clear dtr bit */
  47.     bra    clrbt(PC)    /* go clear bit */
  48.  
  49. setbt:
  50.     movem.l    D0-D2,-(A7)    /* Save registers */
  51.     move.w    SR,-(A7)    /* Save status */
  52.     ori.w    #0x700,SR    /* IPL 7, disable ints */
  53.     moveq    #14,D1        /* port A */
  54.     move.l    D2,-(A7)    /* save bit # */
  55.     bsr    giaccess(PC)    /* Select port A */
  56.     move.l    (A7)+,D2    /* bit # back */
  57.     or.b    D2,D0        /* Set bits */
  58.     moveq    #0x8E,D1    /* Write to port A */
  59.     bsr    giaccess(PC)    /* write new value */
  60.     move.w    (A7)+,SR    /* Restore status */
  61.     movem.l    (A7)+,D0-D2    /* restore regs */
  62.     rts
  63.  
  64. clrbt:
  65.     movem.l    D0-D2,-(A7)    /* Save registers */
  66.     move.w    SR,-(A7)    /* Save status */
  67.     ori.w    #0x700,SR    /* IPL 7, disable ints */
  68.     moveq    #14,D1        /* port A */
  69.     move.l    D2,-(A7)    /* save bit # */
  70.     bsr    giaccess(PC)    /* Select port A */
  71.     move.l    (A7)+,D2    /* bit # back */
  72.     and.b    D2,D0        /* Set bits */
  73.     moveq    #0x8E,D1        /* Write to port A */
  74.     bsr    giaccess(PC)    /* write new value */
  75.     move.w    (A7)+,SR    /* Restore status */
  76.     movem.l    (A7)+,D0-D2    /* restore regs */
  77.     rts
  78. }
  79.     
  80. /* main - Determine if argument is "on" or "off". Assume "off" if no arg.
  81.           Process DTR accordingly. */
  82.  
  83.     
  84. main(argc,argv)
  85. int argc;
  86. char *argv[];
  87. {
  88.     if(argc > 1 && strcmp(argv[1],"on")==0){
  89.         Supexec(&dtron);
  90.         printf ("DTR has been turned on\n");
  91.     }
  92.     else{
  93.         Supexec(&dtroff);
  94.         printf ("DTR has been turned off\n");
  95.     }
  96.     
  97. }
  98.  
  99.  
  100.